/** @format */

import { app } from "../../App";
import { mFrameConfigConst } from "../../Const/FrameConfigConst";

declare const h5Api: any;
/**
 * 4399网页sdk
 */
export class Sdk4399Web {
    private h5Api: any = null;

    constructor() {
        this.h5Api = h5Api;
    }

    //登录
    public async login() {
        return new Promise((resolve) => {
            resolve("ok");
        });
    }

    //分享给好友
    public share(): void {
        this.h5Api.share();
    }

    //提交分数
    // { "code":1001, "msg": "未知错误" }
    // { "code":1002, "msg": "参数不全" }
    // { "code":1006, "msg": "用户认证失败" }
    // { "code":3001, "msg": "排行榜权限未开通" }
    // { "code":3002, "msg": "该排行榜不存在" }
    // { "code":3003, "msg": "榜单未生效" }
    public submit(score: number): void {
        this.h5Api.submitRankScore(mFrameConfigConst.rankId, score, function (res) {
            app.log.log("提交结果：", res.data.score, res.data.rank);
            switch (res.code) {
                case 1000:
                    app.log.log("提交成功");
                    this.h5Api.showRankList();
                case 1001:
                    app.log.log("未知错误");
                    break;
                case 1002:
                    app.log.log("参数不全");
                    break;
                case 1006:
                    app.log.log("用户认证失败");
                    break;
                case 3001:
                    app.log.log("排行榜权限未开通");
                    break;
                case 3002:
                    app.log.log("该排行榜不存在");
                    break;
                case 3003:
                    app.log.log("榜单未生效");
                    break;
            }
        });
    }

    //显示排行榜
    public showRank(): void {
        this.h5Api.showRankList();
    }

    //显示更多好玩
    public showMore(): void {
        this.h5Api.showRecommend();
    }

    //激励视频
    public showAd(): void {}

    /***********************************商业化************************************ */

    //banner广告
    public showBannerAd(): void {}

    //隐藏banner广告
    public hideBannerAd(): void {}

    //插屏广告
    public showInterstitialAd(): void {}
}
